package com.example.project.controller.project;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.project.annotation.Log;
import com.example.project.core.controller.BaseController;
import com.example.project.core.domain.AjaxResult;
import com.example.project.core.page.TableDataInfo;
import com.example.project.entity.TimeActivitie;
import com.example.project.enums.BusinessType;
import com.example.project.service.TimeActivitieService;
import com.example.project.utils.poi.ExcelUtil;	

/**
 * 时间活动ControllerO
 * 
 * @author ruoyi
 * @date 2025-11-17
 */
@Controller
@RequestMapping("/project/activitie")
public class TimeActivitieController extends BaseController {

	private String prefix = "pm/activitie";

	@Autowired
	private TimeActivitieService timeActivitieService;

	@RequiresPermissions("project:activitie:view")
	@GetMapping()
	public String activitie() {
		return prefix + "/activitie";
	}

	/**
	 * 查询时间活动列表
	 */
	@RequiresPermissions("project:activitie:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TimeActivitie timeActivitie) {
		startPage();
		List<TimeActivitie> list = timeActivitieService.selectTimeActivitieList(timeActivitie);
		return getDataTable(list);
	}

	/**
	 * 导出时间活动列表
	 */
	@RequiresPermissions("project:activitie:export")
	@Log(title = "时间活动", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	@ResponseBody
	public AjaxResult export(TimeActivitie timeActivitie) {
		List<TimeActivitie> list = timeActivitieService.selectTimeActivitieList(timeActivitie);
		ExcelUtil<TimeActivitie> util = new ExcelUtil<TimeActivitie>(TimeActivitie.class);
		return util.exportExcel(list, "时间活动数据");
	}

	/**
	 * 新增时间活动
	 */
	@RequiresPermissions("project:activitie:add")
	@GetMapping("/add")
	public String add() {
		return prefix + "/add";
	}

	/**
	 * 新增保存时间活动
	 */
	@RequiresPermissions("project:activitie:add")
	@Log(title = "时间活动", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TimeActivitie timeActivitie) {
		return toAjax(timeActivitieService.insertTimeActivitie(timeActivitie));
	}

	/**
	 * 修改时间活动
	 */
	@RequiresPermissions("project:activitie:edit")
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap) {
		TimeActivitie timeActivitie = timeActivitieService.selectTimeActivitieById(id);
		mmap.put("timeActivitie", timeActivitie);
		return prefix + "/edit";
	}

	/**
	 * 修改保存时间活动
	 */
	@RequiresPermissions("project:activitie:edit")
	@Log(title = "时间活动", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TimeActivitie timeActivitie) {
		return toAjax(timeActivitieService.updateTimeActivitie(timeActivitie));
	}

	/**
	 * 删除时间活动
	 */
	@RequiresPermissions("project:activitie:remove")
	@Log(title = "时间活动", businessType = BusinessType.DELETE)
	@PostMapping("/remove")
	@ResponseBody
	public AjaxResult remove(String ids) {
		return toAjax(timeActivitieService.deleteTimeActivitieByIds(ids));
	}
}
